package soul.domain.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import soul.domain.code.Status;

/**
 * Created by sunzhengjie on 2016/11/21.
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Response {

    private int code;

    private Object msg;

    private Object data;

    public static Response ok(Status status) {
        return new Response(status.getCode(), status.getMsg());
    }

    public static Response ok(Status status, String msg){
        return new Response(status.getCode(), msg);
    }

    public static Response ok(Status status, Object data) {
        return new Response(status.getCode(), status.getMsg(), data);
    }

    private Response(int code, Object msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    private Response(int code, Object msg) {
        this(code, msg, null);
    }

    private Response() {

    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getMsg() {
        return msg;
    }

    public void setMsg(Object msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
